package com.wswy.wzcx.ui.fragment;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;

import com.che.libcommon.ui.BaseFragment;
import com.wswy.wzcx.R;
import com.wswy.wzcx.module.InternalMsgCodeKt;
import com.wswy.wzcx.ui.other.CloseDelegate;
import com.wswy.wzcx.ui.persenter.WZDBPresenter;

/**
 * Created by wangduheng26 on 2018/3/22.
 * wangduheng26@gmail.com
 */

public class WZDBFragment extends ILoginFragment {
    public static final String TAG = "WZDBFragment";
    FrameLayout frameLayout;
    WZDBPresenter presenter;
    private CloseDelegate delegate;

    public static WZDBFragment newInstance() {
        Bundle args = new Bundle();
        WZDBFragment fragment = new WZDBFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        Context context = getContext();
        assert context != null;
        frameLayout = new FrameLayout(context);
        //frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.default_background_color));
        presenter = new WZDBPresenter(context);
        presenter.onCreate(frameLayout);
        return frameLayout;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        presenter.onActivityCreate(savedInstanceState);
        delegate = new CloseDelegate(this, InternalMsgCodeKt.UPLOAD_COMPLETE_WDZD);
    }

    @Override
    public void setupPage() {
        presenter.setupPage();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        presenter.onDestroy();
        if (delegate != null)
            delegate.onDestroy();

    }

    @Override
    public String getFragmentTitle() {
        return "选择代办车辆";
    }

}
